<template>
  <div>
    <div v-if="isShow1" style="position: absolute;top: 130px;left: 20px;z-index: 999;">
      <GongShuiScan /> 
    </div>
    <keep-alive>
      <div class="main-popup-con" :style=" {right: this.comname == 'YuJingTongJi' ? '1600px' : '200px' }">
        <component v-show="isShow" :is="comname"></component>
      </div>
    </keep-alive>
  </div>
</template>

<script>
  import Bus from "@/js/EventBus";
  import QueryInfo from "@/components/MainPopup/QueryInfo";
  import BaoGuanAnalysis from '@/components/MainPopup/BaoGuanAnalysis.vue';
  import GuanFaAnalysis from '@/components/MainPopup/GuanFaAnalysis.vue';
  import JianXiuAnalysis from '@/components/MainPopup/JianXiuAnalysis.vue';
  import KaiWaAnalysis from '@/components/MainPopup/KaiWaAnalysis.vue';
  import LianTongAnalysis from '@/components/MainPopup/LianTongAnalysis.vue';
  import ZongDuanMianAnalysis from '@/components/MainPopup/ZongDuanMianAnalysis.vue';

  import GongShuiScan from '@/components/MainPopup/GongShuiScan.vue';
  import YuJingTongJi from '@/components/MainPopup/YuJingTongJi.vue';
  import ZiDingYiTongJi from '@/components/MainPopup/ZiDingYiTongJi.vue';
  import GongShuiTotal from "@/components/MainPopup/GongShuiTotal.vue";


  export default {
    name: "MainPopup",
    computed: {
    },
    components: {
      QueryInfo,
      BaoGuanAnalysis,
      GuanFaAnalysis,
      JianXiuAnalysis,
      KaiWaAnalysis,
      LianTongAnalysis,
      ZongDuanMianAnalysis,
      GongShuiScan,
      YuJingTongJi,
      ZiDingYiTongJi,
      GongShuiTotal
    },
    data () {
      return {
        comname: 'QueryInfo',
        isShow: false,
        isShow1: false,
        componentsList: {
          [this.GLOBAL.QUERYINFO]: 'QueryInfo',
          [this.GLOBAL.BAOGUAN]: 'BaoGuanAnalysis',
          [this.GLOBAL.LIANTONG]: 'LianTongAnalysis',
          [this.GLOBAL.ZONGDUANMIAN]: 'ZongDuanMianAnalysis',
          [this.GLOBAL.JIANXIU]: 'JianXiuAnalysis',
          [this.GLOBAL.KAIWA]: 'KaiWaAnalysis',
          [this.GLOBAL.GUANFA]: 'GuanFaAnalysis',
          [this.GLOBAL.GONGSHUIZONGLAN]: 'GongShuiTotal',
          [this.GLOBAL.YUJINGTONGJI]: 'YuJingTongJi',
          [this.GLOBAL.ZIDINGYICHAXUN]: 'ZiDingYiTongJi'
        }
      };
    },
    computed: {
      isUseComponent () {

      }
    },

    mounted () {
      Bus.$on(this.GLOBAL.QUERYINFO, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.BAOGUAN, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.LIANTONG, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.ZONGDUANMIAN, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.JIANXIU, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.KAIWA, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.GUANFA, (item) => {

        this.showPopupComponent(item);
      });

      Bus.$on(this.GLOBAL.GONGSHUIZONGLAN, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.YUJINGTONGJI, (item) => {

        this.showPopupComponent(item);
      });
      Bus.$on(this.GLOBAL.ZIDINGYICHAXUN, (item) => {

        this.showPopupComponent(item);
      });

      //切换菜单时关闭功能项输入项弹框
      Bus.$on(this.GLOBAL.CLOSEMAINPOPUP, () => {
        this.isShow = false;
        this.isShow1 = false;
      });

    },

    methods: {
      /**
       * 点击二级菜单出现输入项弹框
       * @param {*} item 菜单项
       */
      showPopupComponent (item) {
        this.comname = this.componentsList[item.value];
        if (this.comname == 'GongShuiTotal') {
          this.isShow1 = true;
        } else {
          this.isShow1 = false;
        }
        this.isShow = item.isActive;
      },
    },
  };
</script>

<style lang="scss" scoped>
  .main-popup-con {
    width: auto;
    height: auto;
    position: absolute;
    top: 130px;
    right: 200px;
    z-index: 999;
    // background-color: red;
  }
</style>